package com.ruoyi.project.system.joinus.controller;

import com.ruoyi.common.utils.PageQuery;
import com.ruoyi.framework.web.page.TableData;
import com.ruoyi.project.system.joinus.service.IJoinusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.joinus.domain.Joinus;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * joinusController
 * 
 * @author ruoyi
 * @date 2024-07-17
 */
@Api("加入我们")
@Controller
@RequestMapping("/system/joinus")
public class JoinusController extends BaseController
{
    private String prefix = "system/joinus";

    @Autowired
    private IJoinusService joinusService;

    @GetMapping()
    public String joinus()
    {
        return prefix + "/joinus";
    }

    /**
     * 查询joinus列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableData<Joinus> list(Joinus joinus, PageQuery pageQuery)
    {
        return joinusService.selectList(joinus, pageQuery);
    }

    /**
     * 新增joinus
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存joinus
     */
    @ApiOperation("add")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Joinus joinus)
    {
        return toAjax(joinusService.insert(joinus));
    }

    /**
     * 修改joinus
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Joinus aJoinus = joinusService.selectById(id);
        mmap.put("aJoinus", aJoinus);
        return prefix + "/edit";
    }

    /**
     * 修改保存joinus
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Joinus joinus)
    {
        return toAjax(joinusService.update(joinus));
    }

    /**
     * 删除joinus
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(joinusService.deleteByIds(ids));
    }
}
